package com.woniuxy.ams.service.impl;

import com.woniuxy.ams.dao.AssessStandardDao;
import com.woniuxy.ams.dao.AssessTypeDao;
import com.woniuxy.ams.entity.AssessStandard;
import com.woniuxy.ams.entity.AssessType;
import com.woniuxy.ams.service.AssessStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AssessStandardServiceImpl implements AssessStandardService {

    @Autowired
    AssessStandardDao assessStandardDao;

    @Autowired
    AssessTypeDao assessTypeDao;

    /**
     * 查找所有指标
     *
     * @return
     */
    @Override
    public List<AssessStandard> findAllAssessStandard(AssessStandard data) {
        return assessStandardDao.findAllAssessStandard(data);
    }

    /**
     * 添加指标
     *
     * @param assessStandard
     * @return
     */
    @Override
    public boolean addAssessStandard(AssessStandard assessStandard) {
        int i = assessStandardDao.addAssessStandard(assessStandard);

        if (i == 1) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 删除指标
     *
     * @param assessStandard
     * @return
     */
    @Override
    public boolean deleteAssessStandard(AssessStandard assessStandard) {
        Integer id = assessStandard.getId();
        int i = assessStandardDao.deleteAssessStandard(id);

        if (i == 1) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 更改指标
     *
     * @param assessStandard
     * @return
     */
    @Override
    public boolean updateAssessStandard(AssessStandard assessStandard) {
        int i = assessStandardDao.updateAssessStandard(assessStandard);

        if (i == 1) {
            return true;
        } else {
            return false;
        }
    }


    /**
     * 根据name查询指标
     *
     * @param assessStandard
     * @return
     */
    @Override
    public List<AssessStandard> findByAssessmentStandardName(AssessStandard assessStandard) {
        String name = assessStandard.getName();

        return assessStandardDao.findByAssessmentStandardName(name);
    }


    /**
     * 根据id查找指标
     *
     * @param assessStandard
     * @return
     */
    @Override
    public List<AssessStandard> findById(AssessStandard assessStandard) {
        int id = assessStandard.getId();
        return assessStandardDao.findById(id);
    }

    /**
     * 查询所有(无分页供item使用)
     *
     * @return
     */
    @Override
    public List<AssessStandard> findAll() {
        return assessStandardDao.findAll();
    }

    @Override
    public int[] findTheassessmentNameByName(AssessStandard assessStandard) {
        String name = assessStandard.getName();
        return assessStandardDao.findTheassessmentNameByName(name);
    }

    @Override
    public AssessStandard find(String name ,String assessmentTypes) {
        return assessStandardDao.find(name,assessmentTypes);
    }

    @Override
    public int findIdByName(String name) {
        return assessStandardDao.findIdByName(name);
    }


}
